# coding: utf-8
from application import db


class Bilibili(db.Model):
    __tablename__ = 'bilibili'

    id = db.Column(db.Integer, primary_key=True, info='id')
    title = db.Column(db.String(255, 'utf8mb4_bin'), info='标题')
    BV = db.Column(db.String(255, 'utf8mb4_bin'), info='BV号')
    bofang_num = db.Column(db.Integer, info='播放量')
    create_time = db.Column(db.String(255, 'utf8mb4_bin'), info='b站发布时间')
    newtime = db.Column(db.String(255, 'utf8mb4_bin'), info='添加时间')
    jianjie = db.Column(db.String(255, 'utf8mb4_bin'), info='简介')
    love_num = db.Column(db.Integer, info='收藏数')
    img_url = db.Column(db.String(255, 'utf8mb4_bin'), info='封面')
    up_img_url = db.Column(db.String(255, 'utf8mb4_bin'), info='up头像')
    name = db.Column(db.String(255, 'utf8mb4_bin'), info='')

    def __init__(self, **items):
        for key in items:
            # 判断是否有这个属性或方法
            if hasattr(self.key):
                # 给对象的属性赋值，若属性不存在，先创建再赋值。
                setattr(self.key, items[key])
